<template>
  <el-table :data="tableData" stripe style="width: 100%">
    <el-table-column prop="title" label="标题" width="180">
    </el-table-column>
    <el-table-column prop="author" label="作者" width="180">
    </el-table-column>
    <el-table-column prop="category" label="分类">
    </el-table-column>
    <el-table-column prop="content" label="内容">
    </el-table-column>
    <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" icon="el-icon-delete" circle @click="open(scope.row)"></el-button>
        </template>
      </el-table-column>
  </el-table>
</template>

<script>
import {selectOfficial,delOfficial} from "../../../api/research"
export default {
  mounted(){
    this.selectOfficial();
  },
  data() {
    return {
      tableData: []
    }
  },
  methods: {
    selectOfficial(){
      selectOfficial().then(res => {
      console.log(res);
      this.tableData=res.result;
    })
    },
    open(row) {

      let id = {
        officialId: row.officialId
      }

      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          delOfficial(id).then(res => {
            console.log(res);
            if (res.code == 200) {
              this.selectOfficial();
              this.$message.success(res.message)
            } else {
              this.$message.error(res.message)
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
    },
  },

}
</script>

<style scoped></style>
